package org;

import org.newdawn.slick.SlickException;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.geom.Polygon;

public abstract class LevelObject {

	/*
	 this class is used for everything in the game.
	 Block are a levelObject, so player and enemies are etc ..
	 this class create a polygon around an object, used for collision tests
	 and sets a few common methods and variable all children classes can share..
	*/
	
    public float x;  // x of an object
    public float y;  // y of an object
    public String type; // string i use to give a little name to objects
    public Polygon poly; // poly to be built around the object for coll. tests
    public boolean onGround; // onGround boolean for player and enemies 

    public LevelObject(
            float x, float y,
            float topLeftX, float topLeftY,
            float topRightX, float topRightY,
            float downRightX, float downRightY,
            float downLeftX, float downLeftY,
            String type) {
    	
        this.x = x;
        this.y = y;
        this.type = type;

        poly = new Polygon(new float[]{
                topLeftX, topLeftY,
                topRightX, topRightY,
                downRightX, downRightY,
                downLeftX, downLeftY
        });        
    }
    
    public abstract void update(int delta) throws SlickException;
    public abstract void draw(Graphics g);
    
    public int isCollisionWith(LevelObject other) throws SlickException {
        return 0;//poly.intersects(other.poly);
    }
}

